home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 002 / document.arc / DBASEII.DOC < prev    next >
Encoding:
Text File  |  1984-03-10  |  14.3 KB  |  331 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.                       NOTES ON USE OF CCDB FILES WITH DBASEIItm
  8.  
  9.  
  10.           These  remarks  are  designed for the dBaseII user with a general
  11.           familiarity with dBaseII but without experience in use  of  files
  12.           created  outside dBaseII.  Underlined words in the examples below
  13.           are as typed by a user.
  14.  
  15.           Data Base Set-up
  16.  
  17.           In order to work with a data  set,  dBaseII  must  first  convert
  18.           the  data  into  its  own  format.  Fortunately, this is a fairly
  19.           straightforward process.  The  user  should  be  aware,  however,
  20.           that  these  data  in  dBaseII  format  generally occupy 15 to 35
  21.           percent more space than in the comma-delimited format as provided
  22.           by  the  Bureau.   The  following  suggestions assume the user is
  23.           working with a machine with two 320 or 360 kb floppy disk drives.
  24.  
  25.           1.   If you plan to work with all of  a  file  which  is  120  to
  26.                160  kb  in  comma-delimited  format,  transfer the incoming
  27.                file onto the same disk as your dBaseII  system  using  COPY
  28.                or another systems utility prior to starting dBaseII.
  29.  
  30.           2.   "Create"  the  file  structure  for  dBaseII.  You will need
  31.                to enter in a name, type and field length  for  every  field
  32.                on  the  incoming file.  The following assumes you are using
  33.                the incoming file CCDB01.TXT as is.
  34.  
  35.                . CREATE
  36.                FILENAME:  B:COUNTY01                   (any name you select)
  37.                FIELD   NAME,TYPE,WIDTH,DECIMAL PLACES
  38.                001     GEOG8001,C,5
  39.                002     FLAG0011,N,1
  40.                003     LAND8001,N,7
  41.                004     FLAG0012,N,1
  42.                005     POPG7001,N,9
  43.                             .
  44.                             .
  45.                INPUT DATA NOW?  NO
  46.  
  47.                The name for each field can be  either  the  mnemonic  label
  48.                presented  in  the  data  dictionaries, or anything else you
  49.                choose within dBaseII naming  conventions  (e.g.  up  to  10
  50.                characters  long).   The  type  is  usually  N (numeric) for
  51.                flags and data  items,  and  usually  C  (character  string)
  52.                for  area  names  and  codes.   The width is the field size,
  53.                and errors will result if too few characters are  allocated.
  54.                The data dictionary shows the maximum digits required nationwide
  55.                for  each  item.  Decimal places need not be specified since
  56.                only integers are presented  on  the  files  (although  some
  57.                items have implied decimals).
  58.           _____________________
  59.           dBaseII is a trademark of Ashton-Tate
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.           2
  74.  
  75.                You  must  list  every field on the incoming file, including
  76.                flags.  If you want to extract only certain fields or  merge
  77.                fields  from  more  than one file, this may be done with the
  78.                UTILITYC program before  entering  dBaseII,  or  in  dBaseII
  79.                as  discussed  below  in  item  6.  (Note:  if you are using
  80.                an abbreviated  data  dictionary  created  by  the  UTILITYC
  81.                program,  don't  forget  that this format fails to list area
  82.                codes and flags even though they are still  present  in  the
  83.                data file.)
  84.  
  85.           3.   Load  the  incoming  data  into  the structure you have just
  86.                created.
  87.  
  88.                . USE B:COUNTY01
  89.                . APPEND FROM A:CCDB01.TXT DELIMITED
  90.  
  91.                If you want to enter in only certain kinds  of  records  you
  92.                may  make  that selection at this time.  For example, APPEND
  93.                FROM  A:CCDB01.TXT  FOR  $(GEOG8001,1,2)  =  "06"  DELIMITED
  94.                would  load  only data for California (state code 06).  This
  95.                kind of geographic extraction can also be done in the UTILITYC
  96.                program.  Extraction based on characteristics  can  be  done
  97.                only in dBaseII, e.g., APPEND FROM A:CCDB01.TXT FOR POPG8001
  98.                >= 50000 DELIMITED.
  99.  
  100.                A bug in dBaseII  is  that  occasionally  the  system  fails
  101.                to  capture the last few records when appending from a comma
  102.                delimited file.  If you find  that  the  number  of  records
  103.                is  slightly  less than it should be (e.g., 3189 in a county
  104.                file or 1008 in a city file), then you  will  need  to  take
  105.                the following actions:
  106.  
  107.                a.   Create  a  dummy  data  base with the same structure as
  108.                     the current data base using COPY  STRUCTURE  TO  DUMMY.
  109.                     Enter that file with USE DUMMY.
  110.  
  111.                b.   Create  several  dummy  records, for example, using the
  112.                     APPEND command and entering in zeroes  in  each  field.
  113.                     Enter COPY TO DUMMY.TXT DELIMITED.  
  114.  
  115.                c.   Add  the dummy records to your original comma delimited
  116.                     data file using the Copy command in DOS, after quitting
  117.                     dBaseII.  COPY filename.txt + DUMMY.TXT TO filename.txt.
  118.  
  119.                d.   Reenter  your  original  data  base in dBaseII and find
  120.                     out what was the last area  code  read  into  the  file
  121.                     earlier (e.g. GO BOTTOM then DISPLAY).
  122.  
  123.                e.   Append  the  remaining  records  from  the now-extended
  124.                     comma-delimited file  using  APPEND  FROM  filename.txt
  125.                     FOR  GEOG8001  >  "code", where "code" is the area code
  126.                     for the last record previously appended, e.g., "56041".
  127.             
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.                                                                           3
  140.  
  141.           4.   Link area names from a separate file.  As originally  issued
  142.                by  the  Bureau,  area names are on a separate file from any
  143.                of the data.  That file can be loaded  into  dBaseII  format
  144.                using  CREATE  and APPEND as discussed above.  The following
  145.                example assumes names have been loaded into COUNTY00.DBF.
  146.  
  147.                . USE B:COUNTY00
  148.                . SELECT SECONDARY
  149.                . USE B:COUNTY01
  150.                . SET LINKAGE ON
  151.  
  152.                The last command allows you to work with data for  the  same
  153.                area  in  both  files  when  you ask for any given record in
  154.                either file, assuming both files  feature  records  for  the
  155.                same  areas  in  the  same  order.  The first file is termed
  156.                the Primary file,  the  second  the  Secondary  file.   "P."
  157.                and  "S."  prefixes  are  used to tell dBaseII which file to
  158.                look in.  For example to list  by  name  all  counties  with
  159.                a population over 1,000,000, type DISPLAY P.GEOG8002, S.POPG8001
  160.                FOR  S.POPG8001  >= 1000000 .AND. $(S.GEOG8001,3,3) > "000".
  161.                (The last phrase, beginning with $, eliminates  state  total
  162.                records from the display.)
  163.  
  164.                Working  with  two  linked files at once can be tricky.  For
  165.                instance, if you have worked with either file before  typing
  166.                SET  LINKAGE  ON  you must first enter GO TOP for both files
  167.                to ensure  that  the  right  records  are  linked  together.
  168.                A  preferred  approach  would  be  to  extract and merge the
  169.                desired fields into  a  single  file  using  UTILITYC  prior
  170.                to  entering dBaseII, or in dBaseII using the UPDATE command
  171.                as described below in item 6.
  172.  
  173.           5.   Resorting or ranking records.  Sorted lists can be  prepared
  174.                using  either SORT or INDEX.  Indexing is usually preferred.
  175.                The following would  sort  all  counties  into  rank  order,
  176.                then  list  those  with  a  population over 500,000 in order
  177.                (identified only by code).
  178.  
  179.                . USE B:COUNTY01
  180.                . INDEX ON -POPG8001 TO B:POPRANK
  181.                . USE B:COUNTY01 INDEX B:POPRANK
  182.                . DISPLAY GEOG8001,POPG8001 FOR POPG8001 > 500000 .AND.
  183.                    $(GEOG8001,3,3) > "000" 
  184.  
  185.                Note that the indexing variable is presented as a  negative.
  186.                DBaseII  indexes  only  in  ascending  order,  so making the
  187.                value negative is necessary to get the  list  in  descending
  188.                order of population.  To display area names from a different
  189.                file, instead of codes, add the following commands:
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.           4
  206.  
  207.                . GO TOP
  208.                . SELECT SECONDARY
  209.                . USE B:COUNTY00 INDEX B:POPRANK
  210.                . DISPLAY S.GEOG8002,P.POPG8001 FOR POPG8001 > 500000 .AND.
  211.                    $(GEOG8001,3,3) > "000"
  212.  
  213.           6.   Merge data from multiple files.  When you want to  use  data
  214.                from  more  than  2  files  at  once, or when you are having
  215.                difficulty linking two files as described  in  items  4  and
  216.                5,  CREATE  a  new  data base with all of the desired fields
  217.                and UPDATE the data into it,  as  illustrated  below.   This
  218.                can  be  done  as  long as you have enough space on a single
  219.                device (diskette or hard disk)  to  accommodate  the  merged
  220.                file,  and  as  long  as you do not need to put more than 32
  221.                fields into a single file (a dBaseII limitation).
  222.  
  223.                . CREATE A COUMERGE
  224.                FIELD     NAME,TYPE,WIDTH,DECIMAL PLACES
  225.                001       GEOG8001,C,5        (geographic i.d. on all files)
  226.                002       GEOG8301,C,4
  227.                003       GEOG8302,C,2        (geographic fields from CCDB00.TXT
  228.                004       GEOG8303,C,4          now loaded into COUNTY00.DBF)
  229.                005       GEOG8101,C,4
  230.                006       GEOG8002,C,30
  231.                007       POPG7001,N,9        (selected data from CCDB01.TXT
  232.                008       POPG8001,N,9          now loaded into COUNTY01.DBF)
  233.                009       FLAG0244,N,1        (selected data from CCDB24.TXT
  234.                010       MONY7930,N,5          now loaded into COUNTY24.DBF)
  235.                011       _
  236.                INPUT DATA NOW?  N
  237.                . USE A:COUMERGE
  238.                . APPEND FROM B:COUNTY00
  239.                . GO TOP
  240.                . RESET
  241.                . UPDATE ON GEOG8001 FROM B:COUNTY01 REPLACE POPG7001,POPG8001
  242.                . GO TOP
  243.                . RESET
  244.                . UPDATE ON GEOG8001 FROM B:COUNTY24 REPLACE FLAG0244,MONY7930
  245.  
  246.                In creating merged files of  especially  selected  items  it
  247.                is  tempting  to  drop  all flag fields.  In some cases this
  248.                is quite appropriate.  Some items, e.g.,  total  population,
  249.                have  no  flags other than zero.  In some applications, e.g.
  250.                ranking areas, there is no way  to  make  use  of  the  flag
  251.                and  the  flag  can  be  dropped.   This can be accomplished
  252.                by copying the data to  another  file  using  a  field  list
  253.                which omits unwanted flags.
  254.  
  255.                On  the  other  hand,  in  routine data display, some flags,
  256.                such as 4 for suppression for disclosure reasons, are important
  257.                to show.  One alternative is to  replace  the  zero  in  the
  258.                data  field  with  the negative of the flag value (e.g., -4)
  259.                and drop the flag.  In subsequent  displays  it  would  then
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.                                                                           5
  272.  
  273.                be necessary to screen fields for negative values and display
  274.                a  message  instead  of  a  data  value.  This approach must
  275.                be avoided wherever real negative values  may  occur  (e.g.,
  276.                farm  earnings)  or  where  you will want to use the data in
  277.                calculations without prior screening.
  278.  
  279.           7.   Pack data where necessary.  In some cases it may seem important
  280.                to have on one file more  than  32  data  fields.   One  way
  281.                around  this  dBaseII  limitation  is to store several items
  282.                within a single character string.  For example, if  in  step
  283.                2 above we had added at the end of the record a 50-character
  284.                type-C field named MERGEPOP we could pack all  the  original
  285.                data  items  and  their  flags  into that field, which could
  286.                later be moved to a consolidated data file.  For example,
  287.  
  288.                . USE B:COUNTY01
  289.                . REPLACE ALL MERGEPOP WITH STR(FLAG0011,1) + STR(LAND8001,7)
  290.                    + STR(FLAG0012,1) + STR(POPG7001,9) + ...
  291.  
  292.                Any subsequent reference  would  then  require  use  of  the
  293.                substring  function.   For  example, to reconstruct POPG7001
  294.                use VAL($(MERGEPOP,10,9)), i.e., the value of the  substring
  295.                within  MERGEPOP  beginning  with  the  10th character and 9
  296.                characters in length.
  297.  
  298.                Consolidation of merged files into a single data base  would
  299.                require  creating  a  separate data base with fields defined
  300.                to accept the merged character strings.
  301.  
  302.                . CREATE A COUMERGE
  303.                FIELD     NAME,TYPE,WIDTH,DECIMAL PLACES
  304.                001       GEOG8001,C,5
  305.                002       MERGEPOP,C,50
  306.                003       MERGEAGE,C,45
  307.                004       _
  308.                INPUT DATA NOW?  N
  309.                . USE A:COUMERGE
  310.                . APPEND FROM B:COUNTY01
  311.                . GO TOP
  312.                . RESET
  313.                . UPDATE ON GEOG8001 FROM B:COUNTY04 REPLACE MERGEAGE
  314.  
  315.                Packing data this way into long character strings is extravagant
  316.                of disk space, and impractical to use if the  original  file
  317.                occupies  a  large  part  of available disk space.  The only
  318.                purpose it serves is to circumvent  the  dBaseII  limitation
  319.                to 32 fields.
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.